<template>
  <div class="tables-edit-outer">
    <div class="tables-edit-con">
      <Icon :type="signName" class="expand-sign" @click="toggle"/>
      <span class="value-con">{{ value }}</span>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Expand',
  props: {
    value: [String, Number],
    edittingCellId: String,
    params: Object,
    editable: Boolean
  },
  data () {
    return {
      signName: 'ios-add',
      expand: false
    }
  },
  methods: {
    handleInput (val) {
      this.$emit('input', val)
    },
    toggle () {
      this.expand = !this.expand
      if (this.signName === 'ios-add') {
        this.signName = 'ios-remove'
      } else {
        this.signName = 'ios-add'
      }
    },
    startEdit () {
      this.$emit('on-start-edit', this.params)
    },
    saveEdit () {
      this.$emit('on-save-edit', this.params)
    },
    canceltEdit () {
      this.$emit('on-cancel-edit', this.params)
    }
  }
}
</script>

<style lang="less">
.tables-edit-outer{
  height: 100%;
  .tables-edit-con{
    position: relative;
    height: 100%;
    .value-con{
      vertical-align: middle;
    }
    .tables-edit-btn{
      position: absolute;
      right: 10px;
      top: 0;
      display: none;
    }
    &:hover{
      .tables-edit-btn{
        display: inline-block;
      }
    }
  }
  .tables-editting-con{
    .tables-edit-input{
      width: ~"calc(100% - 60px)";
    }
  }
}

.expand-sign{
  color: #1c8631;
  font-size: 18px;
  cursor: pointer;
}
</style>
